package com.mouse.controller.user;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mouse.common.lang.Result;
import com.mouse.entity.GeneCategory;
import com.mouse.entity.GeneComposition;
import com.mouse.entity.vo.GeneCategoryVO;
import com.mouse.entity.vo.GeneCompositionVO;
import com.mouse.mapper.GeneCompositionMapper;
import com.mouse.service.GeneCompositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author godson
 * @since 2022-08-07
 */
@RestController
@RequestMapping("/gene-composition")
public class GeneCompositionController {

    @Autowired
    private GeneCompositionMapper geneCompositionMapper;


    @Autowired
    private GeneCompositionService geneCompositionService;
    @GetMapping("/by-gac/")
    public Result getGeneCompositionByGAC(@RequestParam String gac) throws UnsupportedEncodingException {
        String converted = URLDecoder.decode(gac,"UTF-8");
        Page<GeneComposition> page = new Page<>(1,10);
        Page<GeneComposition> pages = geneCompositionMapper.getGeneCompositionByGAC(page,converted);

        return Result.succ(pages);
    }

    @GetMapping("/info/{gcid}")
    public Result getInfo(@PathVariable(name="gcid") Long gcid){
        GeneComposition geneComposition = geneCompositionService.getById(gcid);
        GeneCompositionVO geneCompositionVO = geneCompositionService.getGeneCompositionVO(geneComposition);
        return Result.succ(geneCompositionVO);

    }






}
